
$j(document).ready(function () {
	$('searchValue').value = getInvoker().getSearchValue();
});

var isClick = false; //用于防止点击多次保存
//增加属性后的回调函数
function addCallback(attribute){
	if(!isClick){
		isClick = true;
		var isQuickSearch = $('isQuickSearch').value;
		var showStyle = $('showStyle').value;
		var searchValue = $('searchValue').value;
		var searchOption = {'isQuickSearch':isQuickSearch,'showStyle':showStyle,'searchValue':searchValue};
		if (opener && !opener.closed) {
			//如果是打开window的方式，使用下面代码
			if (opener.addAttributeCallback) 
				opener.addAttributeCallback(attribute,searchOption);//调用回调函数将attribute回传给主form
				window.close();
		}else if(parent){
			//如果是iframe的方式，使用下面代码
			if (parent.closeAttributeDefineDialog) 
				parent.addAttributeCallback(attribute,searchOption);
				parent.closeAttributeDefineDialog();
		}
	}
}
//编辑属性后的回调函数		
function editCallback(attribute){
	/**
	var returnString = "[Success]\r\n";
	returnString += "attributeId:"+attribute.attributeId+"\r\n";
	returnString += "attributeName:"+attribute.attributeName+"\r\n";
	returnString += "attributeType:"+attribute.attributeType+"\r\n";
	returnString += "attributeDataType:"+attribute.attributeDataType+"\r\n";
	returnString += "defaultValue:"+attribute.defaultValue+"\r\n";
	returnString += "isRequired:"+attribute.isRequired+"\r\n";
	returnString += "status:"+attribute.status;
	alert(returnString);
	**/
	if(!isClick){
		isClick = true;
		var isQuickSearch = $('isQuickSearch').value;
		var showStyle = $('showStyle').value;
		var searchValue = $('searchValue').value;
		var searchOption = {'isQuickSearch':isQuickSearch,'showStyle':showStyle,'searchValue':searchValue};
		if (opener && !opener.closed) {
			//如果是打开window的方式，使用下面代码
			if (opener.addAttributeCallback) 
				opener.editAttributeCallback(attribute,searchOption);//调用回调函数将attribute回传给主form
				window.close();
		}else if(parent){
			//如果是iframe的方式，使用下面代码
			if (parent.closeAttributeDefineDialog) 
				parent.editAttributeCallback(attribute,searchOption);
				parent.closeAttributeDefineDialog();
		}
	}
}
//开启关闭快速搜索
function changeQuickSearch(){
	var isQuickSearchCheck = $('isQuickSearchCheck');
	var isQuickSearch = $('isQuickSearch');
	if(isQuickSearchCheck.checked){
		isQuickSearch.value = 1;
		$j('#quickSearchOptionSpan').show();
	}else{
		isQuickSearch.value = 0;
		$j('#quickSearchOptionSpan').hide();
	}
}

//返回调用者 parent 或者opener
function getInvoker(){
	if (opener && !opener.closed) {
	//如果是打开window的方式，使用下面代码
		return window;
	}else if(parent){
	//如果是iframe的方式，使用下面代码
		return parent;
	}
}
